package com.njwd.rpc.provider.wsimpl;

import org.springframework.stereotype.Component;

import com.alibaba.dubbo.rpc.RpcException;
import com.njwd.common.rpc.ResponseVo;
import com.njwd.rpc.api.SmsServices;

@Component("SmsServicesImpl")
public class SmsServicesImpl implements SmsServices {

	@Override
	public ResponseVo<Boolean> sendSms(String mobile) {
		System.out.println(mobile);
		if (mobile.startsWith("153")) {
			throw new RuntimeException("senderror");
		}
		if (mobile.startsWith("143")) {
			try {
				//配置超时3s，为了测试超时 这里设定4s
				Thread.currentThread().sleep(4 * 1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		if (mobile.startsWith("163")) {
			throw new RpcException("senderror");
		}
		return ResponseVo.getSuccessResponse(true);
	}

}
